<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
	<HEAD>
		<?php
			@include 'config.include.php';
			$klasse = "";
			$sqlStatement = "";
			
			$id = "";
			if (isset($_SESSION['id'])) {
				$id = $_SESSION['id'];
			}
	
	if ($id == "stuff") {
		if (isset($_REQUEST['klasse'])) {
			$klasse = $_REQUEST['klasse'];
		}

		$includedSource = true;
		@include "vertretungen.php";

		$vertretungen = getStundenplanByWoche($klasse, $verbindung);
		
		$sqlStatement .= "SELECT kts.idTag as 'Tag', kts.idStunde as 'Stunde', r.bezeichnung as 'Raumnummer', l.Kurzname as 'Kuerzel', u.Kurzname as 'Fach' ";
		$sqlStatement .= "FROM Klasse_Tag_Stunde kts, Unterrichtsfach u, Raum r, Lehrer l, Klasse k ";
		$sqlStatement .= "WHERE kts.idKlasse = k.idKlasse AND k.bezeichnung = '$klasse' ";
		$sqlStatement .= "AND kts.Lehrer_idLehrer = l.idLehrer AND kts.idRaum = r.idRaum ";
		$sqlStatement .= "AND kts.Unterrichtsfach_idUnterrichtsfach = u.idUnterrichtsfach;";
		
		$ergebnisse = @mysql_query($sqlStatement, $verbindung);
		
		$zeiten = array("07:45-08:30", "08:30-09:15","09:30-10:15","10:15-11:00","11:30-12:15","12:15-13:00","13:15-14:00","14:00-14:45","15:00-15:45","15:45-16:30");
		
		$stunden = array();
		
		while($y = mysql_fetch_assoc($ergebnisse)){
			$stunden[$y["Tag"]][$y["Stunde"]-1] = $y;
		}
	}

 	else {
 		$error = "401";
		@header("http/1.0 401 Authentication required"); 
 	}
	?>
</HEAD>
<STYLE>
* {
	color: white;
	font-family: Arial;
}
		.vertretung{
			background-color:#ff0000;
		}
tr


:not

 

(
:first-child

 

){
height


:

 

10%
}
table {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	right: 0;
	width: 100%;
	heigth: 100%;
}
td {
	text-align: center;
}
</STYLE>
<BODY style="background-color: #000000;">
	<?php if ( $error == "401" ) : ?>
	<h1>Autorisierung fehlgeschlagen!</h1>
	<?php return; endif; ?>
	<?php extract($vertretungen); ?>
<table width="100%" height = 100%>
			<thead>
				<tr height="9.0909%">
					<th width="16.6%">Zeiten</th>
					<th width="16.6%"><?= ucwords("mo") ?></th>
					<th width="16.6%"><?= ucwords("di") ?></th>
					<th width="16.6%"><?= ucwords("mi") ?></th>
					<th width="16.6%"><?= ucwords("do") ?></th>
					<th width="16.6%"><?= ucwords("fr") ?></th>
				</tr>
			</thead>
			<tbody>
				<?php for ( $i = 0; $i < 10; ++$i ) : ?>
				<tr height="9.0909%">
					<th>
						<span><?= $i+1 ?>. Stunde</span><br/>
						<span><?= $zeiten[$i] ?></span>
					</th>
					<?php
						for($j = 1; $j < 6; $j++) :
						if ( isset($vertretung[$j][$i])) :
					?>
					<td class="vertretung">
						<span class="fach"><?= $stunden[$j][$i]["Fach"] ?></span><br/>
						<span class="lehrer"><?= $vertretung[$j][$i]["Kuerzel"] ?></span><br/>
						<span class="raum"><?= $vertretung[$j][$i]["Raumnummer"] ?></span><br/>
					</td>
					<?php else: ?>
					<td>
						<span class="fach"><?= $stunden[$j][$i]["Fach"] ?></span><br/>
						<span class="lehrer"><?= $stunden[$j][$i]["Kuerzel"] ?></span><br/>
						<span class="raum"><?= $stunden[$j][$i]["Raumnummer"] ?></span><br/>
					</td>
					<?php endif;
						endfor;
				?>
				</tr>
				<?php 
					endfor;
				?>
			</tbody>
		</table>

</BODY>
<?php
@include 'config.disconnect.php';
?>
</HTML>

<!-- // BACKUP-ZENTRUM -->


<!-- 		<TR align='center'> -->
			<TD><?php //echo $i.". Stunde<br/>".$zeiten[$i-1]; ?></TD>
			<?php
// 			for($j = 1; $j < 6; $j++){
// 			?>
			<TD><?php //echo $stunden[$j][$i]["Fach"]; ?> <br /> <?php //echo $stunden[$j][$i]["Kuerzel"] ?>
				<br /> <?php //echo $stunden[$j][$i]["Raumnummer"]; ?></TD>
			<?php
// 				}
// 				?>
<!-- 		</TR> -->
